package com.cyy.singleton_pattern;

/**
 * 单例模式(饿汉式——线程安全)
 */
public class HungryMode {
    private static HungryMode hungryMode = new HungryMode();
    private String name;

    public static synchronized HungryMode getInstance(){
        return hungryMode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "HungryMode{" +
                "name='" + name + '\'' +
                '}';
    }
}
